package com.hzhr.iot.core.util;

import com.hzhr.iot.core.constant.HzhrHeaderNames;

import java.util.HashMap;
import java.util.Map;

public class HzhrIotUtil {
     public static Map<String, String>  initGlobalHeader(Map<String, String> header) {
         Map<String, String> newHeader = new HashMap<>();

         newHeader.putAll(header);
         if (header.get(HzhrHeaderNames.USER_ID) != null) {
             newHeader.put(HzhrHeaderNames.USER_ID, header.get(HzhrHeaderNames.USER_ID));
         } else {
             newHeader.put(HzhrHeaderNames.USER_ID, "0");
         }

         newHeader.put(HzhrHeaderNames.USER_CODE, "0");

         if (header.get(HzhrHeaderNames.USER_NAME) != null) {
             newHeader.put(HzhrHeaderNames.USER_NAME, header.get(HzhrHeaderNames.USER_NAME));
         } else {
             newHeader.put(HzhrHeaderNames.USER_NAME, "system");
         }

         newHeader.put(HzhrHeaderNames.COMPANY_ID, "0");
         newHeader.put(HzhrHeaderNames.DEPT_ID, "0");
         newHeader.put(HzhrHeaderNames.USER_TYPE, "3");

         return newHeader;
     }
}
